package com.salt.system.model.domain;

import com.salt.common.model.BaseEntity;
import com.salt.system.enums.SysUserState;
import com.salt.system.handlers.SysUserStateHandler;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import tk.mybatis.mapper.annotation.ColumnType;

import javax.persistence.*;

/**
 * 系统用户
 *
 * @author HaiBo Kuang
 * @date 2021年04月15日 上午 11:13
 */
@EqualsAndHashCode(callSuper = false)
@Data
@AllArgsConstructor
@NoArgsConstructor
@Table(name = "sys_user")
public class SysUser extends BaseEntity {
    /**
     * 用户id
     */
    @Id
    @Column(name = "id")
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    /**
     * 用户名 唯一
     */
    @Column(name = "user_name")
    private String userName;
    /**
     * 密码
     */
    @Column(name = "password")
    private String password;
    /**
     * 用户状态
     */
    @ColumnType(column = "state", typeHandler = SysUserStateHandler.class)
    private SysUserState state;
    /**
     * 启用状态 true or false
     */
    @Column(name = "enabled", columnDefinition = "tinyint(1) default 1")
    private Boolean enabled;
    /**
     * 电话号码 唯一
     */
    @Column(name = "phone")
    private String phone;
}
